package com.xiaoye.qbproject.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xiaoye.qbproject.domain.ZbModule;
import com.xiaoye.qbproject.mapper.ZbModuleMapper;
import com.xiaoye.qbproject.service.ZbModuleService;
import com.xiaoye.qbproject.vo.SetZbInfoAndZbModuleVo;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Administrator
 * @description 针对表【ZB_MODULE(装备组件)】的数据库操作Service实现
 * @createDate 2024-12-27 03:00:22
 */
@Service
public class ZbModuleServiceImpl extends ServiceImpl<ZbModuleMapper, ZbModule>
        implements ZbModuleService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void setZbInfoAndZbModule(SetZbInfoAndZbModuleVo setZbInfoAndZbModuleVo) {
        // 删除旧的关系
        baseMapper.removeRelation(setZbInfoAndZbModuleVo.getZbInfoId());
        // 更新新的关系
        baseMapper.setRelation(setZbInfoAndZbModuleVo.getZbInfoId(), setZbInfoAndZbModuleVo.getZbModuleIds());
    }
}




